package setup

import (
	"fmt"
	"net/http"
	"time"

	"goweb/ext/settings"
	"goweb/routers"
	"goweb/service/auth"
)

func SetUp(path string) {
	conf.SetUpConf(path)
	conf.LogInit()

	auth.InitPer()
	auth.GetAllUserPer()

}

func Web() {
	router := controller.InitRouter()
	s := &http.Server{
		Addr:           fmt.Sprintf(":%d", int(conf.ServerBase.HttpPort)),
		Handler:        router,
		ReadTimeout:    time.Duration(conf.ServerBase.ReadTimeOut) * time.Second,
		WriteTimeout:   time.Duration(conf.ServerBase.WriteTimeOut) * time.Second,
		MaxHeaderBytes: 1 << 20,
	}
	s.ListenAndServe()
}
